package br.unicamp.ic.sgct.server.dominio.entidades;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import br.unicamp.ic.sgct.client.dominio.to.AreaTO;
import br.unicamp.ic.sgct.server.recursos.persistencia.LOGGER;

@Entity(name = "Area")
@Table(name = "T_AREA")
@TableGenerator(name = "AREA_GEN", allocationSize = 1, initialValue = 1, table = "T_ID",
pkColumnName = "key", valueColumnName = "valor", pkColumnValue = "ID_AREA")
public class Area implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -4495990899692824828L;
    @Id
    @Column(name = "id_area")
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "AREA_GEN")
    private Long id;
    @Column(length = 50, nullable = false)
    private String nome;
    @Column(length = 200)
    private String descricao;


    

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getNome() {
        return nome;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public String getDescricao() {
        return descricao;
    }

    public AreaTO getTo() {
        LOGGER.debug("AreaTO getTo");
        AreaTO to = new AreaTO();
        to.setId(getId());
        to.setNome(nome);
        to.setDescricao(descricao);
        return to;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (getId() ^ (getId() >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Area other = (Area) obj;
        if (getId() != other.getId()) {
            return false;
        }
        return true;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }
}
